/*
 * @Author: aggfb 714740235@qq.com
 * @Date: 2024-04-18 23:06:08
 * @LastEditors: aggfb 714740235@qq.com
 * @LastEditTime: 2024-04-18 23:19:23
 * @FilePath: \stepper_motor\bsp\bsp_dac.c
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include "bsp_dac.h"

void bsp_dac_init(void)
{
    rcu_periph_clock_enable(RCU_GPIOA);
    rcu_periph_clock_enable(RCU_DAC);

    gpio_init(GPIOA, GPIO_MODE_AIN, GPIO_OSPEED_50MHZ, GPIO_PIN_4);
    gpio_init(GPIOA, GPIO_MODE_AIN, GPIO_OSPEED_50MHZ, GPIO_PIN_5);

    dac_deinit(DAC0);
    dac_trigger_disable(DAC0, DAC_OUT0);
    dac_wave_mode_config(DAC0, DAC_OUT0, DAC_WAVE_DISABLE);
    dac_output_buffer_enable(DAC0, DAC_OUT0);
    dac_enable(DAC0, DAC_OUT0);
    dac_data_set(DAC0, DAC_OUT0, DAC_ALIGN_12B_L, 0x7FF0);

    dac_trigger_disable(DAC0, DAC_OUT1);
    dac_wave_mode_config(DAC0, DAC_OUT1, DAC_WAVE_DISABLE);
    dac_output_buffer_enable(DAC0, DAC_OUT1);
    dac_enable(DAC0, DAC_OUT1);
    dac_data_set(DAC0, DAC_OUT1, DAC_ALIGN_12B_L, 0x7FF0);
}
